<template>
  <div>
    <a-card :bordered="false" style="height: 100%">
      <a-button @click="handleShowFilter" icon="filter"
        >筛选 <span class="filter-num" style="margin-left: 5px">{{ ' ' + filteredNums }}</span></a-button
      >
      <a-button @click="showColumn" icon="unordered-list" class="btns">设置列</a-button>
      <div class="right-btn">
        <a-button @click="handleAdd" type="primary" class="btns" v-if="hasButton('proOrder:add')"> +新建</a-button>
      </div>
      <a-table
        :loading="loadingTable"
        :customRow="customRow"
        :key="tableKey"
        row-key="id"
        size="middle"
        :scroll="{ x: scrollX, y: 'calc(100vh - 366px)' }"
        :columns="columns"
        :dataSource="modelList"
        :pagination="false"
        class="j-table-force-nowrap"
        @change="handleChange"
        :components="drag(columns, 'LIFE_INSTEND_SETTITOAOP_LIST')"
      >
        <!-- 以下三个为新增修改 -->
        <div slot="customTitle" style="font-weight: 700; float: right; margin-right: -5px">序号</div>
        <div slot="customTitle1" >
          <div style="font-weight: 700;margin-left: 20px">字段名称</div>
        </div>
        <div
          slot="fieldName"
          slot-scope="text"
          style="overflow-x: hidden; max-width: 140px; text-overflow: ellipsis;"
        >
          {{ text }}
        </div>

        <div slot="selectDropdown" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOrder">
          <a-select
            mode="multiple"
            placeholder="请选择"
            allowClear
            style="width: 188px"
            v-model="filterForm[selectkeys(column.dataIndex)]"
            @change="(v) => changeSelect(v, selectkeys(column.dataIndex))"
          >
            <a-select-option v-for="(item, i) in selectOptions(column.dataIndex)" :key="i" :value="item.value"
              >{{ item.label }}
            </a-select-option>
          </a-select>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <!-- 输入框搜索 -->
        <div slot="searchInput" slot-scope="{ selectedKeys, confirm, clearFilters, column }" class="searchWorkOrder">
          <a-input
            placeholder="请输入"
            v-model="filterForm[column.dataIndex]"
            style="width: 188px; display: block"
            @pressEnter="requestData"
          />
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(selectedKeys, confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="searchIcon"
          slot-scope="filtered"
          type="search"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <!-- 日期搜索 -->
        <div slot="datePicker" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOrder">
          <a-range-picker
            style="width: 230px"
            v-model="dateForm[column.dataIndex]"
            format="YYYY-MM-DD"
            :placeholder="['开始时间', '结束时间']"
            @change="(v) => onOk(v, column.dataIndex)"
          />
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <div slot="actions" style="cursor: pointer" slot-scope="text, record" title="拖拽排序">
          <a style="margin-right: 5px" @click="onClickEdit(record)" v-if="hasButton('proOrder:edit')">编辑</a>
          <a-divider type="vertical" v-if="hasButton('proOrder:delete')" />
          <a style="margin-left: 5px" class="ant-dropdown-link" @click="onClickDelete(record.id)" v-if="hasButton('proOrder:delete')">删除</a>
        </div>
        <div
          slot="sort"
          style="cursor: pointer; display: flex; justify-content: center;"
          slot-scope="text, record, index"
          title="拖拽排序"
        >
          <a-icon type="menu" style="font-size: 20px" />
          <span style="font-size: 16px; margin-left: 0; margin-right: 20px; margin-left: 10px">{{ index + 1 }}</span>
        </div>
        <!-- 人员选择 -->
        <div slot="selectPeople" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <j-select-user-by-dep
            @changeRow="usercreateByFun"
            v-model="createBy"
            :seldep="true"
            :modalWidth="1000"
            :multi="true"
            v-if="column.dataIndex == 'createByName'"
          ></j-select-user-by-dep>
          <j-select-user-by-dep
            @changeRow="userupdateByFun"
            v-model="updateBy"
            :seldep="true"
            :modalWidth="1000"
            :multi="true"
            v-if="column.dataIndex == 'updateByName'"
          ></j-select-user-by-dep>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="dateIcon"
          slot-scope="filtered"
          type="filter"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
      </a-table>
      <SetColumn
        columnName="设置列"
        ref="SetColumn"
        v-if="showSetColumn"
        @sureBtn="sureBtn"
        @cancelBtn="showSetColumn = false"
      />
    </a-card>
    <a-drawer placement="right" width="500" :visible="showFilter" @close="closeFilter">
      <div class="filter-body">
        <div slot="title" class="uni-card filter-tit">
          筛选 <span class="filter-num">{{ filteredNums }}</span>
        </div>
        <div class="uni-card" v-if="filteredNums > 0" style="background: #fff">
          <div v-for="(item, i) in filteredList" :key="i" v-show="item.text" class="tag-wrap">
            <span class="filter-tag" @click="delFiltered(item.key)">
              <span class="tag-text">{{ `${item.title}：${item.text}` }}</span>
              <a-icon type="close" style="float: right" />
            </span>
          </div>
        </div>
        <div style="overflow-y: scroll; flex: 1; padding: 0">
          <div class="uni-card" style="background: #fff">
            <a-form-model ref="ruleForm" layout="vertical" :model="filterForm">
              <a-form-model-item label="字段名称">
                <a-input v-model="filterForm.fieldName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="字段类型" prop="fieldType">
                <a-select v-model="filterForm.fieldType" mode="multiple" placeholder="请选择">
                  <a-select-option v-for="item in formTypeList" :value="item.value">
                    {{ item.title }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
              <a-form-model-item style="width: 100%" label="创建人">
                <j-select-user-by-dep
                  @changeRow="createByFun"
                  v-model="createBy"
                  :seldep="true"
                  :modalWidth="1000"
                  :multi="true"
                ></j-select-user-by-dep>
              </a-form-model-item>
              <a-form-model-item label="更新人">
                <j-select-user-by-dep
                  @changeRow="updateByFun"
                  v-model="updateBy"
                  :seldep="true"
                  :modalWidth="1000"
                  :multi="true"
                ></j-select-user-by-dep>
              </a-form-model-item>
              <a-form-model-item label="更新时间">
                <a-range-picker
                  :value="timeValue1"
                  style="width: 100%"
                  :placeholder="['请输入', '请输入']"
                  @change="updateTimeF"
                />
              </a-form-model-item>
              <a-form-model-item label="创建时间">
                <a-range-picker
                  :value="timeValue2"
                  style="width: 100%"
                  :placeholder="['请输入', '请输入']"
                  @change="createTimeF"
                />
              </a-form-model-item>
            </a-form-model>
          </div>
        </div>
        <div class="footer-submit">
          <a-button class="margin-btn" @click="resetFilter">重置</a-button>
          <a-button type="primary" @click="handleFilter">确定</a-button>
        </div>
      </div>
    </a-drawer>
    <!-- 全选/分页 -->
    <div
      class="uni-card pagination-contian"
      :style="{
        position: 'fixed',
        bottom: 0,
        right: 0,
        zIndex: 2,
        left: collapsed ? '197px' : '76px',
        background: '#fff',
        paddingLeft: '43px',
      }"
    >
      <div class="check-contain" style="display: inline-block">
        <span>
          {{ `共 ${total} 条` }}
        </span>
      </div>
      <div style="display: inline-block; float: right">
        <a-pagination
          style="z-index: 999999"
          :total="total"
          v-model="current"
          :page-size-options="pageSizeOptions"
          :page-size="pageSize"
          @change="onChangePage"
          @showSizeChange="onShowSizeChange"
          show-quick-jumper
          show-size-changer
        />
      </div>
    </div>
    <!-- 全屏表单 -->
    <windowForm ref="windowForm"></windowForm>
    <windowDetail ref="windowDetail" @refresh="handleSearch"></windowDetail>
  </div>
</template>
<script>
import SetColumn from '@/pubComponent/SetColumn.vue'
import crumbs from '@/components/crumbs.vue'
import {
  getNewColumns,
  subStrText,
  camelCase2UnderLine,
  commafyTofixedTwo,
  validateDuplicateValue,
  dateCheck,
  getNewColumnsDx,
} from '@/utils/util'
import { deleteAction, postAction } from '@/api/manage'

// import { APILX } from '@/api/requestLx'
import productionApi from '@/api/productionOrder'
import { ClientFormList, getFieldTypeDict } from '@/api/productOrder'
import { mapState } from 'vuex'
import { getDictModel } from '@/api/goodsManagement'
import { getEnableOne } from '@/api/api'
import tableDragResize from '@/mixins/tableDragResize'
// import { API } from '@api/requestFzs'
import windowForm from './createProductionOrder.vue'
import enumData from '@/utils/enumData'
import windowDetail from './inspectionApplicationDetail.vue'
import moment from 'moment'
import { hasButton } from '@/utils/hasPermission'
// import { getAction } from '@/api/action'
// 表头
const columnsValue = [
  {
    title: '序号',
    // ellipsis: true,
    width: 60,
    // align: 'right',
    dataIndex: 'sort',
    key: 'sort', //自定义表头
    slots: { title: 'customTitle' }, //自定义表头
    scopedSlots: {
      customRender: 'sort',
    },
  },
  {
    title: '字段名称',
    // ellipsis: true,
    dataIndex: 'fieldName',
    key: 'fieldName', //自定义表头
    slots: { title: 'customTitle1' }, //自定义表头
    width: 150,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'fieldName',
    },
  },
  {
    title: '字段类型',
    ellipsis: true,
    dataIndex: 'fieldTypeStr',
    width: 150,
  },
  {
    title: '创建时间',
    ellipsis: true,
    dataIndex: 'createTime',
    width: 150,
    sorter: true,
  },
  {
    title: '更新时间',
    ellipsis: true,
    dataIndex: 'updateTime',
    width: 150,
    sorter: true,
    scopedSlots: {
      filterDropdown: 'updateTime',
      filterIcon: 'dateIcon',
      customRender: 'status',
    },
  },
  {
    title: '创建人',
    ellipsis: true,
    dataIndex: 'createByName',
    width: 150,
    scopedSlots: {
      filterDropdown: 'selectPeople',
      filterIcon: 'dateIcon',
      customRender: 'createByName',
    },
  },
  {
    title: '更新人',
    ellipsis: true,
    dataIndex: 'updateByName',
    width: 150,
    scopedSlots: {
      filterDropdown: 'selectPeople',
      filterIcon: 'dateIcon',
      customRender: 'updateByName',
    },
  },
]
const actionArr = [
  {
    fixed: 'right',
    title: '操作',
    width: 110,
    dataIndex: 'actions',
    ellipsis: true,
    scopedSlots: { customRender: 'actions' },
  },
]
export default {
  name: 'waitSend', //待派发列表
  mixins: [tableDragResize],
  props: {
    formType: {
      type: String,
      default: '1',
    },
  },
  data() {
    return {
      dateFilterForm:{},
      timeValue1: [],
      timeValue2: [],
      loadingTable: false,
      sourceVal: '',
      sourceIndex: '',
      createBy: '',
      updateBy: '',
      showcreateBy: '',
      showupdateBy: '',
      cuttentTab: '1',
      verify: {
        verifierRemark: '',
        verifierStatus: 1,
      },
      managementAbnormalEvent: [],
      sendDialog: false, // 派发至车间
      sendForm: {
        causeId: '',
        processDescription: '',
      },
      personList: [],
      enumData,
      verifyshow: false,
      routingList: [],
      verifierStatusList: [
        {
          routeId: 1,
          telecomName: '通过',
        },
        {
          routeId: 2,
          telecomName: '不通过',
        },
      ],

      confirmloading: false,
      labelCol: { span: 6 },
      wrapperCol: { span: 17 },
      maxValue: '',
      formTypeList: [],
      sendRules: {
        processDescription: [{ required: true, message: '请输入', trigger: 'change' }],
      },
      verifyrule: {
        verifierStatus: [{ required: true, message: '请输入', trigger: 'change' }],
      },
      sessionParams: {},
      columnsValue,
      commafyTofixedTwo,
      //人员组件 客户经理
      moment,
      subStrText,
      selectedRowKeys: [],
      showFilter: false, // 筛选抽屉
      tableKey: 1,
      modelList: [], // 列表数据
      showSetColumn: false, // 显示
      // 排序
      sortForm: {
        sortType: '',
        sortColumn: '',
      },
      dateForm: {} /* 筛选日期绑定对象 */,
      current: 1,
      total: 0,
      pageSize: 30,
      pageSizeOptions: ['10', '20', '30', '40', '50'],
      maxPlanProductNum: '',
      columns: [],
      filterForm: {
        fieldName: undefined,
        fieldType: [],
        createBy: '',
        updateBy: undefined,
        createTime: '',
        updateTime: '',
      },
      filteredFormLable: {
        fieldType: '字段类型',
        fieldName: '字段名称',
        createBy: '创建人',
        updateBy: '更新人',
        createTime: '创建时间',
        updateTime: '更新时间',
      },
    }
  },

  //   watch: {
  //   'filterForm.fieldType': {
  //     handler: function (newValue, oldValue) {
  //      if(!newValue){
  //       this.filterForm.fieldType = []
  //      }
  //     },
  //     deep: true
  //   }
  // },
  components: {
    windowForm,
    SetColumn,
    crumbs,
    windowDetail,
  },
  computed: {
    scrollX() {
      let xnum = 0
      for (let item of this.columns) {
        xnum += Number(item.width) || 0
      }
      return xnum
    },
    ...mapState({
      collapsed: (state) => state.user.collapsedAno,
    }),
    filteredList() {
      let list = []
      for (let key in this.filterForm) {
        if (key === 'promiseDate') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm.promiseDateStart
              ? moment(this.filterForm.promiseDateStart).format('YYYY-MM-DD') +
                '~' +
                moment(this.filterForm.promiseDateEnd).format('YYYY-MM-DD')
              : '',
            key,
          })
        } else if (key === 'status' || key === 'eventName') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.statusToTxt(key, this.filterForm[key]),
            key,
          })
        } else if (this.filterForm[key] !== '' && this.filteredFormLable[key] == '创建人') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.showcreateBy,
            key,
          })
        } else if (this.filterForm[key] !== '' && this.filteredFormLable[key] == '更新人') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.showupdateBy,
            key,
          })
        } else if (this.filteredFormLable[key] == '字段类型') {
          let strArr = ''
          for (let item of this.filterForm[key]) {
            for (let each of this.formTypeList) {
              if (item == each.value) {
                strArr += each.text + '，'
              }
            }
          }
          if (strArr) {
            strArr = strArr.substring(0, strArr.length - 1)
          }
          list.push({
            title: this.filteredFormLable[key],
            text: strArr,
            key,
          })
        } else if (key === 'promiseDateStart' || key === 'promiseDateEnd') {
          // 什么都不干
        } else {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm[key],
            key,
          })
        }
      }
      return list
    },
    filteredNums(n) {
      let nums = 0
      for (let key in this.filterForm) {
        if (this.filterForm[key] && this.filterForm[key].length) {
          nums += 1
          if (key === 'promiseDateStart') {
            nums -= 1
          }
        }
      }
      return nums
    },
  },
  created() {
    console.log('created')
    this.initData()
    this.requestData()
    this.getListAll()
  },
  mounted() {},
  methods: {
    hasButton,
    getListAll() {
      getFieldTypeDict().then((res) => {
        if (res.code == 200) {
          console.log(res, 'reeeee')
          this.formTypeList = res.result
        } else {
          this.$message.error(res.message)
        }
      })
    },

    updateTimeF(c) {

      if(c.length == 0){
        this.filterForm.updateTime = ""
        this.dateFilterForm.updateTimeBegin = ''
        this.dateFilterForm.updateTimeEnd = ''
        this.timeValue1 = []
        this.$forceUpdate()
        return
      }
      console.log(c,'cccccccccccccccccccccc');
      this.filterForm.updateTime = moment(c[0]).format('YYYY-MM-DD') + '~' + moment(c[1]).format('YYYY-MM-DD')
      this.dateFilterForm.updateTimeBegin = moment(c[0]).format('YYYY-MM-DD')
      this.dateFilterForm.updateTimeEnd = moment(c[1]).format('YYYY-MM-DD')
      this.timeValue1 = c
      this.$forceUpdate()
    },
    createTimeF(c) {
      if(c.length == 0){
        this.filterForm.createTime = ""
        this.dateFilterForm.createTimeBegin = ''
        this.dateFilterForm.createTimeEnd = ''
        this.timeValue2 = []
        this.$forceUpdate()
        return
      }
      this.filterForm.createTime = moment(c[0]).format('YYYY-MM-DD') + '~' + moment(c[1]).format('YYYY-MM-DD')
      this.dateFilterForm.createTimeBegin = moment(c[0]).format('YYYY-MM-DD')
      this.dateFilterForm.createTimeEnd = moment(c[1]).format('YYYY-MM-DD')
      this.timeValue2 = c
      this.$forceUpdate()
    },

    onClickEdit(record) {
      record.formType = this.formType
      this.$refs.windowForm.initForm(record)
    },
    onClickDelete(id) {
      let that = this
      that.$antdConfirm({
        title: '确定删除自定义字段吗？',
        content: `自定义字段删除后，将同时删除已经在表单中的历史数据，删除后不可恢复`,
        onOk() {
          deleteAction('/basicDynamicFieldConfig/delete', { id }).then((res) => {
            if (res.code == 200) {
              that.current = 1
              that.requestData()
              that.$antdMessage.success('删除成功！')
            } else {
              that.$antdMessage.error(res.message)
            }
          })
        },
        onCancel() {},
      })
    },
    customRow(record, index) {
      return {
        // FIXME: draggable： true 不生效还不晓得是什么原因，先使用鼠标移入事件设置目标行的draggable属性
        props: {
          draggable: 'true',
        },
        on: {
          // 鼠标移入
          mouseenter: (event) => {
            // 兼容IE
            var ev = event || window.event
            ev.target.draggable = true
          }, // 开始拖拽
          dragstart: (event) => {
            // 兼容IE
            var ev = event || window.event // 阻止冒泡
            ev.stopPropagation() // 得到源目标数据
            this.sourceVal = record
            this.sourceIndex = index
          }, // 拖动元素经过的元素
          dragover: (event) => {
            // 兼容 IE
            var ev = event || window.event // 阻止默认行为
            ev.preventDefault()
          }, // 鼠标松开
          drop: (event) => {
            // 兼容IE
            var ev = event || window.event // 阻止冒泡
            ev.stopPropagation() // 得到目标数据
            if (record.orgType == '1') {
              this.$antdMessage.warning('只能对同一个层级之间的上下顺序进行排序')
              return
            }
            this.targetVal = record
            this.targetIndex = index
            console.log(this.targetVal, 'targetVal')
            console.log(this.targetIndex, 'targetIndex')
            if (this.sourceVal.id !== this.targetVal.id) {
              this.resetTableSort(this.sourceVal, this.targetVal, this.sourceIndex, this.targetIndex)
              // if (this.sourceVal.parentId === this.targetVal.parentId) {
              //   this.resetTableSort(this.sourceVal, this.targetVal, this.sourceIndex, this.targetIndex)
              // } else {
              //   this.$antdMessage.warning('只能对同一个层级之间的上下顺序进行排序')
              // }
            }
          },
        },
      }
    },
    // 拖拽结束后根据源目标数据、目标数据重组列表
    resetTableSort(sourceVal, targetVal, sourceIndex, targetIndex) {
      let treeFun = () => {
        let params = {
          id: sourceVal.id,
          formType: sourceVal.formType,
          sort: targetVal.sort,
        }
        this.sorterFun(params)
      }
      treeFun()
    },
    sorterFun(params) {
      let param = params
      this.loadingTable = true
      postAction('/basicDynamicFieldConfig/configSort', param)
        .then((res) => {
          this.loadingTable = false
          if (res.code == 200) {
            this.$antdMessage.success(res.message)
          } else {
            this.$antdMessage.error(res.message)
          }
          this.requestData()
        })
        .catch((err) => {
          this.loadingTable = false
        })
    },

    usercreateByFun(storeVals, row) {
      this.filterForm.createBy = ''
      let newArr = []
      let arrTwo = []
      for (let item of row) {
        newArr.push(item.id)
        arrTwo.push(item.realname)
      }

      if (newArr.length > 0) {
        this.filterForm.createBy = newArr.join(',')
      }
      if (arrTwo.length > 0) {
        this.showcreateBy = arrTwo.join(',')
      }
      this.requestData()
    },
    userupdateByFun(storeVals, row) {
      this.filterForm.updateBy = ''
      let newArr = []
      let arrTwo = []
      for (let item of row) {
        newArr.push(item.id)
        arrTwo.push(item.realname)
      }

      if (newArr.length > 0) {
        this.filterForm.updateBy = newArr.join(',')
      }
      if (arrTwo.length > 0) {
        this.showupdateBy = arrTwo.join(',')
      }
      this.requestData()
    },

    // 创建人
    createByFun(storeVals, row) {
      this.filterForm.createBy = ''
      let newArr = []
      let arrTwo = []
      for (let item of row) {
        newArr.push(item.id)
        arrTwo.push(item.realname)
      }

      if (newArr.length > 0) {
        this.filterForm.createBy = newArr.join(',')
      }
      if (arrTwo.length > 0) {
        this.showcreateBy = arrTwo.join(',')
      }
    },
    updateByFun(storeVals, row) {
      this.filterForm.updateBy = ''
      let newArr = []
      let arrTwo = []
      for (let item of row) {
        newArr.push(item.id)
        arrTwo.push(item.realname)
      }

      if (newArr.length > 0) {
        this.filterForm.updateBy = newArr.join(',')
      }
      if (arrTwo.length > 0) {
        this.showupdateBy = arrTwo.join(',')
      }
    },
    // 排序
    handleChange(pagination, filters, sorter, { currentDataSource }) {
      //console.log('看看这是啥33：', sorter)
      if (sorter.order) {
        let sortType = ''
        if (sorter.order == 'ascend') {
          sortType = 'ASC'
        } else {
          sortType = 'DESC'
        }
        this.sortForm = {
          sortType: sortType,
          // sortColumn: camelCase2UnderLine(sorter.columnKey),
          sortColumn: sorter.columnKey,
        }
        this.current = 1
        this.requestData()
      } else {
        this.sortForm = {
          sortType: '',
          sortColumn: '',
        }
        this.current = 1
        this.requestData()
      }
    },

    // 分页
    onChangePage(current, pageSize) {
      this.current = current
      this.pageSize = pageSize
      this.requestData()
    },
    onShowSizeChange(current, pageSize) {
      this.current = current
      this.pageSize = pageSize
      this.requestData()
    },
    handleSearch(selectedKeys, confirm, dataIndex, clearFilters) {
      this.current = 1
      this.requestData()
    },
    /* 打开筛选 */
    handleShowFilter() {
      this.showFilter = true
    },
    /* 关闭筛选 */
    closeFilter() {
      this.showFilter = false
    },
    /* 确定筛选 */
    handleFilter() {
      this.current = 1
      this.requestData()
      this.showFilter = false
    },
    /* 删除已选 */
    delFiltered(key) {
      console.log(key, 'fieldTypevvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv')
      if (this.filteredFormLable[key] == '客户经理') {
        this.createStr = ''
        this.filterForm[key] = ''
      } else if (key == 'status') {
        this.filterForm[key] = undefined
      } else if (key == 'fieldType') {
        this.filterForm[key] = []
      } else if (key == 'updateTime') {
        this.filterForm[key] = undefined
        this.timeValue1 = []
        this.dateFilterForm.updateTimeBegin = ''
        this.dateFilterForm.updateTimeEnd = ''
      } else if (key == 'createTime') {
        this.filterForm[key] = undefined
        this.timeValue2 = []
        this.dateFilterForm.createTimeBegin = ''
        this.dateFilterForm.createTimeEnd = ''
      } else if (key == 'eventName') {
        this.filterForm[key] = undefined
      } else if (key === 'createBy') {
        this.filterForm.createBy = ''
        this.createBy = ''
      } else if (key === 'updateBy') {
        this.filterForm.updateBy = ''
        this.updateBy = ''
      } else {
        this.filterForm[key] = ''
      }
    },
    /* 重置筛选 */
    resetFilter() {
      this.filterForm = {
        fieldName: '',
        createBy: '',
        updateBy: '',
        fieldType: [],
        updateTime: '',
        createTime: '',
      }
      this.timeValue1 = []
      this.timeValue2 = []
      this.createBy = ''
      this.updateBy = ''
      this.current = 1
      this.dateFilterForm = {}
    },
    /* 初始/加载设置列 */
    initData() {
      let oldValue = localStorage.getItem(this.BUSI_CONST.Entity.LIFE_INSTEND_SETTITOAOP_LIST)

      this.columns = getNewColumnsDx(this.columnsValue, JSON.parse(oldValue), actionArr)
    },

    /* 请求列表数据 */
    requestData() {
      let parameter = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...this.sortForm,
        ...this.filterForm,
        ...this.dateFilterForm
      }
      parameter.formType = this.formType
      parameter.fieldType = parameter.fieldType ? parameter.fieldType.join(',') : ''
      ClientFormList(parameter).then((res) => {
        if (res.code == 200) {
          if (res.result.total) {
            this.total = res.result.total
          } else {
            this.total = 0
          }
          this.modelList = res.result.records
          this.$emit('getNum1', this.total)
        }
      })
    },
    /* 打开设置列面板 */
    showColumn() {
      this.showSetColumn = true
      this.$nextTick(() => {
        this.$refs.SetColumn.paramsData(this.columnsValue, this.BUSI_CONST.Entity.CUSTOMER_LIST, this.columns)
      })
    },
    /* 设置列 */
    sureBtn(emitArr) {
      this.columns = getNewColumnsDx(this.columnsValue, emitArr, actionArr)
      //console.log(this.columns)
      localStorage.setItem(this.BUSI_CONST.Entity.CUSTOMER_LIST, JSON.stringify(emitArr))
      this.tableKey += 1
    },
    /* 导入 */
    importFile() {},
    /* 导出 */
    exportFile() {},
    /* 新建 */
    handleAdd() {
      let record = {
        formType: this.formType,
      }
      this.$refs.windowForm.initForm(record)
    },
    /* 详情 */
    handleDetail(v) {
      console.log(v, 'vvvvvvvv')
      this.$refs.windowDetail.initDetail({
        id: v.id,
        title: '异常反馈详情',
      })
    },
    /* 撤回 */
    handleWithdraw(v) {
      let that = this
      that.$antdConfirm({
        title: '撤回申请将被拒绝',
        content: `确定撤回吗？`,
        onOk() {
          APILX.operateRevoke({ flowInstId: v.flowInstId }).then((res) => {
            if (res.code == 200) {
              that.$antdMessage.success('撤回成功！')
              that.requestData()
            } else {
              that.$antdMessage.error(res.message)
            }
          })
        },
        onCancel() {},
      })
    },
    /* 删除 */
    handleDelete(v) {
      let that = this
      that.$antdConfirm({
        title: '删除后不可恢复',
        content: `确定删除吗？`,
        onOk() {
          APILX.erpCustomerDelete(v.id).then((res) => {
            if (res.code == 200) {
              that.$antdMessage.success('客户删除成功！')
              if (that.modelList.length === 1) {
                that.current = that.current == 1 ? 1 : that.current - 1
              }
              that.requestData()
            } else {
              that.$error({
                title: `${res.message}`,
                content: '无法删除！',
              })
            }
          })
        },
        onCancel() {},
      })
    },
    getClass(type, row) {
      if (type == '承诺交期' && row.promiseDate) {
        if (new Date(row.promiseDate).getTime() < new Date().getTime()) {
          return 'red'
        }
      }
    },
    //点击返回按钮
    goBack() {
      //console.log('goback')
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/public.less';

.flex(@jc, @ai, @fd: row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}

/deep/ .ant-tabs-bar {
  margin: 0;
}

.code-btn {
  margin-left: 10px;
}

/deep/ .ant-form-item-children {
  display: flex;
  align-items: center;
  width: 100%;
  display: inline-block;
}

.j-table-force-nowrap {
  margin-top: @distance1;
}

.btns {
  margin-left: @distance5;
}

.right-btn {
  float: right;
  display: flex;
  justify-content: flex-end;
}

.mg-left {
  margin-left: @distance3;
}

.filter-tit {
  background: #fff;
  border-bottom: 1px solid @greyBorder;
  font-size: @fontSize4;
}

.filter-num {
  color: @normalFont;
}

.filter-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.margin-btn {
  margin-right: @distance5;
}

.filter-tag {
  display: inline-block;
  position: relative;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: @fontSize1;
  line-height: @fontSize1;
  max-width: 100%;
  background: @greyBg;
  color: @titFont;
  cursor: pointer;

  .tag-text {
    display: inline-block;
    padding-right: 20px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .anticon-close {
    position: absolute;
    right: 8px;
    top: 8px;
  }
}

.tag-wrap:nth-of-type(n + 2) {
  margin-top: 10px;
}

.searchWorkOrder {
  .flex(flex-start, center);
  padding: 8px;
}

/deep/ .ant-card-body {
  height: calc(100vh - 300px);
  overflow: hidden;
}

.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}

.ant-dropdown-link {
  color: #ff4d4f;
}

/deep/ .ant-table-header-column {
  width: 100% !important;
}
</style>
